package com.adou.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author:
 * @version: MyAdvise.java v 0.1
 * @date: 2023.04.05
 */
//通知类必须配置成Spring管理的bean
@Component
//设置当前类为切面类类
@Aspect
public class MyAdvise {
    //设置切入点，要求配置在方法上方
    @Pointcut("execution(* com.adou.service.*.*ServiceImpl.*(..))")
    private void pt(){}

    //设置在切入点pt()的前面运行当前操作（前置通知）
//    @Before("pt()")
    public void before(){

        System.out.println("before ");
    }

//    @After("pt()")
    public void after() {


        System.out.println("after ");
    }

    @Around("pt()")
    public void aroud(ProceedingJoinPoint point) throws Throwable {
        System.out.println("before ");

        // 表示对原始操作调用
        point.proceed();
        System.out.println("after ");
    }

}
